from pydantic import computed_field
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    app_name: str = "k-server"

    MYSQL_HOST: str = "192.168.0.15"
    MYSQL_PORT: int = 3306
    MYSQL_USER: str = "root"
    MYSQL_PASSWORD: str = "abc123456."
    MYSQL_DB: str = "zy"
    MYSQL_CHARSET: str = "utf8mb4"

    @computed_field
    @property
    def MYSQL_URI(self) -> str:
        return f"mysql+asyncmy://{self.MYSQL_USER}:{self.MYSQL_PASSWORD}@{self.MYSQL_HOST}:{self.MYSQL_PORT}/{self.MYSQL_DB}?charset={self.MYSQL_CHARSET}"


settings = Settings()